﻿using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using AR.Entities;
using AR.ViewModels.Commands;
using System.Collections.ObjectModel;
using AR.Model;
using System.ServiceModel.DomainServices.Client;
using AR.Web;
using AR.CustomEntities;
using GalaSoft.MvvmLight.Command;
using AR.Views.Candidat;
using AR.ViewModel.Candidat;
using System.Linq;
using AR.Web.Services;

namespace AR.ViewModel.Candidat
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class HistoriqueCandidatViewModel : ViewModelBase
    {

        private readonly CandidatModel model;

        private ObservableCollection<CANDIDAT_HISTORIQUE> _candidatHistoriquesresult;
        public ObservableCollection<CANDIDAT_HISTORIQUE> CandidatHistoriquesResult
        {
            get
            {
                return _candidatHistoriquesresult;
            }
            set
            {
                if (value != _candidatHistoriquesresult)
                {
                    _candidatHistoriquesresult = value;
                    RaisePropertyChanged("CandidatHistoriquesResult");
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the HistoriqueCandidatViewModel class.
        /// </summary>
        public HistoriqueCandidatViewModel()
        {
        }

        public HistoriqueCandidatViewModel(int idCandidat)
        {
            model = new CandidatModel();
            CandidatHistoriquesResult = new ObservableCollection<CANDIDAT_HISTORIQUE>();
            model.FindCandidatHistorique(idCandidat).EntityAdded += HistoriqueCandidatViewModel_EntityAdded;
        }

        private void HistoriqueCandidatViewModel_EntityAdded(object sender, EntityCollectionChangedEventArgs<CANDIDAT_HISTORIQUE> e)
        {
            CandidatHistoriquesResult.Add(e.Entity);
        }
    }
}